﻿using B.S.BasicData.Domain;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Infrastructure.Interfaces;
using B.S.BasicData.Write.Api.Application.Command.W;
using MediatR;

namespace B.S.BasicData.Write.Api.Application.CommandHandler.W
{
    /// <summary>
    /// 回显货运单
    /// </summary>
    public class FullPendingShipmentWaybillsCommandHander : IRequestHandler<FullPendingShipmentWaybillsCommand, ApiResult<PendingShipmentWaybillsModel>>
    {
        /// <summary>
        /// 货运单
        /// </summary>
        private readonly IBaseRepository<PendingShipmentWaybillsModel> _pendingShipmentWaybillsModel;

        public FullPendingShipmentWaybillsCommandHander(IBaseRepository<PendingShipmentWaybillsModel> pendingShipmentWaybillsModel)
        {
            _pendingShipmentWaybillsModel = pendingShipmentWaybillsModel;
        }
        /// <summary>
        /// 回显货运单
        /// </summary>
        /// <param name="request">查询id</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<ApiResult<PendingShipmentWaybillsModel>> Handle(FullPendingShipmentWaybillsCommand request, CancellationToken cancellationToken)
        {
             
            ApiResult<PendingShipmentWaybillsModel> res=new ApiResult<PendingShipmentWaybillsModel>();
            var model= _pendingShipmentWaybillsModel.GetAll().FirstOrDefault(a=>a.Id==request.Id);
            res.Code = ApiEnums.Success;
            res.Msg = "成功";
            res.Data = model;
            return Task.FromResult(res);
        }
    }
}
